﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator
{
    class Node
    {
        private static readonly Dictionary<int, Node> nodeIdSet = new Dictionary<int, Node>();

        private readonly int nodeId;
        private bool visited;

        private Node(int id)
        {
            this.nodeId = id;
            this.visited = false;
        }

        public static Node create(int id)
        {
            Node n = new Node(id);
            if (nodeIdSet.ContainsKey(id))
                return nodeIdSet[id];
            else
                nodeIdSet[id] = n;

            return n;
        }

        public int Id
        {
            get { return Id; }
        }
        public bool Visited
        {
            set { visited = value; }
            get { return visited; }
        }

        public override string ToString()
        {
            return string.Format("Node : {0} : Is Visted {1}", nodeId, visited);
        }
    }
}
